home *** CD-ROM | disk | FTP | other *** search
- /* malloc.c --- p. 137 */
- #include <stdio.h>
- #include <stdlib.h>
- #include <alloc.h>
- #define MAX_CHR 80
- main()
- {
- char *buffer;
- /* Allocate room for string and check for NULL pointer */
- if( (buffer = (char *)malloc(MAX_CHR)) == NULL)
- {
- printf("Allocation Failed.\n");
- exit(0);
- }
- printf("Buffer allocated. Enter string to store: ");
- gets(buffer);
- printf("\nYou entered: %s\n",buffer);
- }